#include <stdio.h>
#include <math.h>

#define MAX_SIZE 50001

int main(int argc, char *argv[])
{
	int a[MAX_SIZE], m, n, ans;
	int i, j, len, t;

	scanf("%d %d", &m, &n);

    if (n < m) {
        t = m; m = n; n = t;
    }
	
	for (i=0; i<n; i++) {
		a[i] = 1;
	}

	a[0] = 0; a[1] = 0;
    len = (int)sqrt((double)n) + 1;
	for (i=2; i<=len; i++) {
		if (a[i] == 0) continue;
		for (j = i*2; j<MAX_SIZE; j+=i) {
			a[j] = 0;
		}
	}

	ans = 0;
	for (i=m; i<=n; i++) {
		if (a[i] == 1) ans++;
	}

	printf("%d\n", ans);

	return 0;
}
